﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.Model;
using Automobile.service.Common;
using Automobile.service.BLL;
using System.Data;
namespace Automobile.service.UI
{
    public partial class Supplier_Upt : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SupplierBLL bll = new SupplierBLL();
            if (!IsPostBack)
            {
                int id = Convert.ToInt32(Request.QueryString["sid"]);
                DataTable table = bll.GetSupplierbyID(id);
                this.HiddenField1.Value = id.ToString();
                Supplier_Name.Value = table.Rows[0]["Supplier_Name"].ToString();
                Supplier_People.Value = table.Rows[0]["Supplier_People"].ToString();
                Supplier_Phone.Value = table.Rows[0]["Supplier_Phone"].ToString();
                Supplier_Addr.Value = table.Rows[0]["Supplier_Addr"].ToString();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SupplierBLL bll = new SupplierBLL();
            Supplier s = new Supplier();
            s.Supplier_Id = int.Parse(HiddenField1.Value);
            s.Supplier_Name = Supplier_Name.Value;
            s.Supplier_People = Supplier_People.Value;
            s.Supplier_Phone = Supplier_Phone.Value;
            s.Supplier_Addr = Supplier_Addr.Value;
            if (bll.uptSupplier(s) > 0)
            {
                JournalBLL jbll = new JournalBLL();
                jbll.AddJourna_uptSupplier(Convert.ToInt32(Session["empid"]),s);
                Response.Write("<script>alert('修改成功！');parent.location.reload(); parent.layer.close(parent.layer.getFrameIndex(window.name));</script>");

            }
            else
            {
                Response.Write("<script>alert('修改失败！'); parent.layer.close(parent.layer.getFrameIndex(window.name));</script>");
            }
        }
    }
}